<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <title>Document</title>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-form" style="margin-top:10px">
        <input type="hidden" name="userId" th:value="${user.userId}" id="userId">
        <div class="layui-form-item">
            <label class="layui-form-label">联系方式</label>
            <div class="layui-input-block">
                <input type="text" name="linkWay" th:value="${user.linkWay}" lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">

            </div>
            <br>
            <label class="layui-form-label">住址</label>
            <div class="layui-input-block">
                <input type="text" name="address" th:value="${user.address}" lay-verify="required" placeholder="请输入备注" autocomplete="off" class="layui-input">

            </div>
            <br>
            <label class="layui-form-label">生日</label>
            <div class="layui-input-block">
                <input type="text" name="bir" th:value="${user.bir}" lay-verify="required" placeholder="请输入备注" autocomplete="off" class="layui-input">

            </div>
            <br>
            <label class="layui-form-label">个人备注</label>
            <div class="layui-input-block">
                <input type="text" name="userRemark" th:value="${user.userRemark}" lay-verify="required" placeholder="请输入备注" autocomplete="off" class="layui-input">

            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="lay-form-submit" id="lay-form-submit">
        </div>

    </div>
</div>

<script th:src="@{/layui/layui.js}"></script>
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        var $ = layui.$;



        //监听提交
        form.on('submit(lay-form-submit)', function(data) {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

            $.ajax({
                type: 'post',
                url: '/User/save',
                data: data.field,
                success: function(json) {
                    // parent.layui.table.reload('lay-table'); //重载表格
                    // var id = $("#userId").val();
                    parent.layer.close(index); //再执行关闭
                    // alert(id);
                    // window.location.href="/User/form?id=" + id;
                    window.parent.location.reload();
                }
            });
        });

    });

</script>

</body>
</html>